﻿<%@ WebHandler Language="C#" Class="GetFolderList" %>

using System;
using System.Web;
using System.IO;
using System.Collections.Generic;
using System.Collections;
public class GetFolderList : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string pathA = HttpContext.Current.Server.MapPath("/manage/upload/image/");
        string path = @pathA;
        context.Response.CacheControl = "no-cache";
        context.Response.Write(JsonHelper.ToJson(FindFolder(path)));
        context.Response.Flush();
        context.Response.End();
    }
    List<String> list = new List<string>();
    public List<string> FindFolder(string SourcePath)
    {

        //遍历文件夹
        DirectoryInfo theFolder = new DirectoryInfo(SourcePath);
        //遍历子文件夹
        DirectoryInfo[] dirInfo = theFolder.GetDirectories();
            foreach (DirectoryInfo NextFolder in dirInfo)
            {
                HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
                list.Add(NextFolder.ToString());
            }
        return list;
    }
    public bool IsReusable {
        get {
            return false;
        }
    }

}